module top_module(
    input [31:0] a,
    input [31:0] b,
    input sub,
    output [31:0] sum
);

    wire			cout1;
    wire			cout0;
    wire	[15:0]	sum1;
    wire	[15:0]	sum0;
    wire	[31:0]	b_in;
    
    assign sum = {sum1, sum0};
    assign b_in = b ^ {32{sub}};
    
    add16 u_add16_0(
        .a(a[15:0]),
        .b(b_in[15:0]),
        .cin(sub),
        .sum(sum0),
        .cout(cout0)
    );
    
    add16 u_add16_1(
        .a(a[31:16]),
        .b(b_in[31:16]),
        .cin(cout0),
        .sum(sum1),
        .cout(cout1)
    );
    
endmodule
